package com.greydawn.ObserverPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: zhongwr
 * @Create: 2021/12/6 21:43
 * @Version 1.0
 * @Description: 被监听的类
 */
public class Subject {

    protected List<Observer> observerList = new ArrayList<>();

    private String message;

    public void setMessage(String message) {
        this.message = message;
        noticeObs();
    }

    private void noticeObs() {
        observerList.forEach(l -> l.copyThat(message));
    }

}
